﻿@model Apps.Models.Flow.Flow_FormModel
@using Apps.Common;
@using Apps.Models.Flow;
@using Apps.Web.Core;
@using Apps.Models.Sys;
@using Apps.Locale;
@using Apps.Models.Enum;
@{ 
    Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
}
<style>

    .tbdetail { width: 98%; border-collapse: collapse; }
.tbdetail .alignRight { width: 150px; text-align: right; }
.tbdetail td { border-bottom: 1px solid #F4F4F4; height: 30px; word-wrap:break-word; word-break:break-all; }
.tbcalendar, .tbcalendar td, .tbcalendar th { border: 1px solid #cccccc; border-collapse: collapse; padding: 5px; text-align: center; }
.tbcalendar th{ background: #f4f4f4; }
</style>
       <div class="tc" style="padding:10px;"> @Model.Name</div>

 <table class="tbdetail">
     @if (Model.StartStep.stepCheckStateList != null)
     {
        <tr>
            <td align="center">
                <table class="tbdetail">
                    <tr>
                        <td class="alignRight">
                           起草人：
                        </td>
                        <td>
                            <table class="tbdetail">
                                @{
                                    foreach (var checkstate in Model.StartStep.stepCheckStateList)
                                    {
                                        <tr>
                                            <td style="width:20%">
                                                @Html.Raw(checkstate.UserName) 
                                            </td>
                                            <td style="width:40%">
                                                起草意见：@(checkstate.Reamrk)
                                            </td>
                                            <td style="width:40%">
                                                起草状态：@(checkstate.CheckFlag == 0 ? "终止申请 " + checkstate.CreateTime.ToString("yyyy-MM-dd HH:mm") : checkstate.CheckFlag == 1 ? "已申请   " + checkstate.CreateTime.ToString("yyyy-MM-dd HH:mm") : "待申请")
                                            </td>
                                        </tr>
                                    }
                                }
                            </table>

                        </td>
                    </tr> 
                </table>
            </td>
        </tr>
        <tr>
            <td align="center">
                ↓
            </td>
        </tr>
                        }
    @{
        int i = 0;
        foreach (var item in Model.stepcheckList)
        {
            i++;
            <tr>
                <td align="center">
                    <table class="tbdetail">
                        <tr>
                            <td class="alignRight">
                                第
                                @item.stepModel.Sort
                                步：
                            </td>
                            <td>
                                @(item.StateFlag==true? @Html.Raw("<span class='label label-green'>" + item.stepModel.Name+ "</span>") : (item.StateFlag == false&&item.ContentId==null) ? @Html.Raw(item.stepModel.Name):item.StateFlag == false?@Html.Raw("<span class='label label-red'>" + item.stepModel.Name + "</span>"): @Html.Raw(item.stepModel.Name))
                            </td>
                        </tr>
                        <tr>
                            <td class="alignRight">
                                流转规则：
                            </td>
                            <td>
                                @(item.stepModel.FlowRule == (int)FlowRuleEnum.Customer ? "指派人" : item.stepModel.FlowRule == (int)FlowRuleEnum.Lead ? "按上级" : item.stepModel.FlowRule == (int)FlowRuleEnum.Position ? "按职位" : item.stepModel.FlowRule == (int)FlowRuleEnum.Department ? "按部门" : "按人员")
                                ( @(item.stepModel.IsAllCheck ? "会签" : "任一") )
                            </td>
                        </tr>
                        <tr>
                            <td class="alignRight">
                                审批人：
                            </td>
                            <td>
                                @if (item.stepCheckStateList.Count > 0)
                                {
                                    <table class="tbdetail">
                                        @{ 
                                            foreach (var checkstate in item.stepCheckStateList)
                                            { 
                                                <tr>
                                                    <td style="width:20%">
                                                         @(checkstate.UserName)
                                                    </td> 
                                                    <td style="width:40%">
                                                        审批意见：@(checkstate.Reamrk)
                                                    </td>
                                                    <td style="width:40%">
                                                        审批状态：@(checkstate.CheckFlag == 0?"未通过 " + checkstate.CreateTime.ToString("yyyy-MM-dd HH:mm") : checkstate.CheckFlag == 1 ? "已通过   " + checkstate.CreateTime.ToString("yyyy-MM-dd HH:mm") : "待审批")
                                                    </td> 
                                                </tr>
                                            }
                                        }
                                    </table>
                                }
                                else
                                {
                                    @(item.stepModel.Execution)
                                }

                            </td>
                        </tr>
                        @{
                            int j = 0;
                            foreach (var judge in item.stepRuleList)
                            {
                                j++;
                                <tr>
                                    <td class="alignRight">
                                        分支
                                        @j：
                                    </td>
                                    <td>
                                        @String.Format("如果 [{0} {1} {2}] → [{3}]", judge.AttrName, judge.Operator, judge.Result, judge.NextStep == "0" ? "流程结束" : judge.NextStepName)
                                    </td>
                                </tr>
                            }
                        }
                    </table>
                </td>
            </tr>
            <tr>
                <td align="center">
                    ↓
                </td>
            </tr>
                            }
    }
    <tr>
        <td align="center">
            流程结束
        </td>
    </tr>
</table>
